//package com.zhouyu.jpademo.service.oneToMany;
//
//import com.zhouyu.jpademo.entity.oneToMany.onway.DepartMent;
//import com.zhouyu.jpademo.entity.oneToMany.onway.Student;
//import com.zhouyu.jpademo.service.BaseTest;
//import com.zhouyu.jpademo.service.StudentService;
//
//import org.junit.Test;
//import org.springframework.beans.factory.annotation.Autowired;
//
//import java.util.ArrayList;
//import java.util.List;
//
//import lombok.extern.log4j.Log4j2;
//
///**
// * @Description:单向映射
// * 1.在一的一方使用@OneToMany  或者
// * 2.在多的一方使用@ManyToOne
// */
//@Log4j2
//public class OneToManyTestOneway extends BaseTest {
//
//  @Autowired
//  StudentService studentService;
//
//  @Test
//  public void add(){
//    DepartMent departMent = new DepartMent();
//    departMent.setName("爱情公寓");
//    Student student = new Student();
//    student.setName("zhouyu");
//    student.setDepartMent(departMent);
//    Student student2 = new Student();
//    student2.setName("shengzuqing");
//    student2.setDepartMent(departMent);
//    ArrayList<Student> students = new ArrayList<>();
//    students.add(student);
//    students.add(student2);
//    studentService.create(students,departMent);
//  }
//
//  @Test
//  public void get(){
//    /**
//     * 多的一方可以级联查询关联的一方
//     * */
//    List<Student> students = studentService.getSudent("zhouyu");
//    log.info("查询学生：{}",students);
//
//    /**
//     * 根据关联外键查询,传外键字段就可以了
//     */
//    DepartMent departMent = studentService.getDepartment(15L);
//    /**根据外键对象查询*/
//    List<Student> sudentList = studentService.getSudentWithDepart(departMent);
//    /**根据外键id查询*/
//    List<Student> sudentList2 = studentService.getSudentWithDepartId(15L);
//    log.info("外键对象查询：{}",sudentList);
//    log.info("外键id查询：{}",sudentList2);
//
//    /**
//     * 一的一方不能够查询到多的一方
//     * */
//    List<DepartMent> department = studentService.getDepartment("爱情公寓");
//    log.info("公寓:{}",department);
//  }
//
//  @Test
//  public void update(){
//    /**
//     * 由于是单向的，被维护的一方不能级联更新
//     */
//    DepartMent departMent = studentService.getDepartment(15L);
//    studentService.updateDepart(departMent);
//  }
//
//  @Test
//  public void delete(){
//    studentService.deleteDepartMent(15L);
//  }
//
//}
